/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pkl53.view;

import java.awt.GridLayout;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import pkl53.component.Textfield;
import pkl53.model.B2Umumusaha;
import pkl53.view.loop.Loop4Usaha;


/**
 *
 * @author Ema Yuland SP
 */
public class BlokUsaha4 extends javax.swing.JPanel {
    
    private ArrayList<Textfield> listTextFieldBlokUsaha4 = new ArrayList<Textfield>();
    private ArrayList<B2Umumusaha> listModel = new ArrayList<B2Umumusaha>();
    private String nama[] = {"loop1", "loop2", "loop3", "loop4", "loop5", "loop6", "loop7", "loop8", "loop9", "loop10"};
    private Loop4Usaha panel;
    private int length;
    
    private BlokUsaha123 blokUsaha123;
    /**
     * Creates new form blok123
     */
    public BlokUsaha4() {
        initComponents();
        addListTextfield();
        
        setloop(2);
    }
    
    public List<Textfield> getListTextFieldBlokUsaha4() {
        return listTextFieldBlokUsaha4;
    }

    public void addListTextfield() {
//        listTextFieldBlok123Usaha.add(0, getB3R1Nama());
//        listTextFieldBlok123Usaha.add(1, getB3R1Art());
//        listTextFieldBlok123Usaha.add(2, getB3R2());
//        listTextFieldBlok123Usaha.add(3, getB3R3());
//        listTextFieldBlok123Usaha.add(4, getB3R4a());
//        listTextFieldBlok123Usaha.add(5, getB3R4b());
//        listTextFieldBlok123Usaha.add(6, getB3R5());
//        listTextFieldBlok123Usaha.add(7, getB3R6());
//        listTextFieldBlok123Usaha.add(8, getB3R7a());
//        listTextFieldBlok123Usaha.add(9, getB3R7b());
//        listTextFieldBlok123Usaha.add(10, getB3R8());
//        listTextFieldBlok123Usaha.add(11, getB3R9());
//        listTextFieldBlok123Usaha.add(12, getB3R10());
//        listTextFieldBlok123Usaha.add(13, getB3R11a());
//        listTextFieldBlok123Usaha.add(14, getB3R12b());
//        listTextFieldBlok123Usaha.add(15, getB3R12c());
//        listTextFieldBlok123Usaha.add(16, getB3R12d());
//        listTextFieldBlok123Usaha.add(17, getB3R13Apr());
//        listTextFieldBlok123Usaha.add(18, getB3R13Mei());
//        listTextFieldBlok123Usaha.add(19, getB3R13agt());
//        listTextFieldBlok123Usaha.add(20, getB3R13des());
//        listTextFieldBlok123Usaha.add(21, getB3R13feb());
//        listTextFieldBlok123Usaha.add(22, getB3R13jan());
//        listTextFieldBlok123Usaha.add(23, getB3R13jul());
//        listTextFieldBlok123Usaha.add(24, getB3R13jun());
//        listTextFieldBlok123Usaha.add(25, getB3R13mar());
//        listTextFieldBlok123Usaha.add(26, getB3R13okt());
//        listTextFieldBlok123Usaha.add(27, getB3R13sep());
//        listTextFieldBlok123Usaha.add(28, getB3R14a());
//        listTextFieldBlok123Usaha.add(29, getB3R14b());
//        listTextFieldBlok123Usaha.add(30, getB3R14c());
//       
//        
   
    }
    
    private EntityManager em;
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        blok4Usaha = new pkl53.imageClass.BlokUsaha4();
        jLayeredPane1 = new javax.swing.JLayeredPane();
        loopPanel = new javax.swing.JPanel();

        setLayout(new java.awt.BorderLayout());

        jLayeredPane1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        javax.swing.GroupLayout loopPanelLayout = new javax.swing.GroupLayout(loopPanel);
        loopPanel.setLayout(loopPanelLayout);
        loopPanelLayout.setHorizontalGroup(
            loopPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1290, Short.MAX_VALUE)
        );
        loopPanelLayout.setVerticalGroup(
            loopPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 360, Short.MAX_VALUE)
        );

        jLayeredPane1.add(loopPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 370, 1290, 360));

        javax.swing.GroupLayout blok4UsahaLayout = new javax.swing.GroupLayout(blok4Usaha);
        blok4Usaha.setLayout(blok4UsahaLayout);
        blok4UsahaLayout.setHorizontalGroup(
            blok4UsahaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(blok4UsahaLayout.createSequentialGroup()
                .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1380, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        blok4UsahaLayout.setVerticalGroup(
            blok4UsahaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1385, Short.MAX_VALUE)
        );

        add(blok4Usaha, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private pkl53.imageClass.BlokUsaha4 blok4Usaha;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JPanel loopPanel;
    // End of variables declaration//GEN-END:variables

    public void setloop(int k) {
        loopPanel.removeAll();;
        getListModel().clear();
        length = k;
        for (int i = 0; i < length; i++) {
            panel = new Loop4Usaha(nama[i]);
            loopPanel.add(panel);
//            getB2Umumusaha1().setKks(getKKS());
//            getB2Umumusaha1().setKKS1 1Art(getKKS()+ Integer.toString(i+1));
            getListModel().add(i, panel.getB2Umumusaha1()); //udahdapat model  
        }
        GridLayout grid = new GridLayout(10, 1, 1, 1);
        loopPanel.setLayout(grid);
        
    }

    /**
     * @return the listModel
     */
    public ArrayList<B2Umumusaha> getListModel() {
        return listModel;
    }

    /**
     * @param listModel the listModel to set
     */
    public void setListModel(ArrayList<B2Umumusaha> listModel) {
        this.listModel = listModel;
    }

    /**
     * @return the blok4Usaha
     */
    public pkl53.imageClass.BlokUsaha4 getBlok4Usaha() {
        return blok4Usaha;
    }

    /**
     * @param blok4Usaha the blok4Usaha to set
     */
    public void setBlok4Usaha(pkl53.imageClass.BlokUsaha4 blok4Usaha) {
        this.blok4Usaha = blok4Usaha;
    }

    

    void setBlokUsaha123(BlokUsaha123 blokUsaha1231) {
        this.blokUsaha123 = blokUsaha1231;
    }

    /**
     * @return the blokUsaha123
     */
    public BlokUsaha123 getBlokUsaha123() {
        return blokUsaha123;
    }
    
    private String getKKS(){
        return (getBlokUsaha123().getB1R1().getText()
                + getBlokUsaha123().getB1R2().getText()
                + getBlokUsaha123().getB1R3().getText()
                + getBlokUsaha123().getB1R4().getText()
                + getBlokUsaha123().getB1R5a().getText()
                + getBlokUsaha123().getB1R5b().getText()
                + getBlokUsaha123().getB1R6().getText());
    }
}
